//
//  LYYRadioCollectionViewCell.m
//  Icar
//
//  Created by dllo on 15/10/23.
//  Copyright © 2015年 小龙侠. All rights reserved.
//

#import "LYYRadioCollectionViewCell.h"

@implementation LYYRadioCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH(90), HEIGHT(90))];
        [self.contentView addSubview:self.imgView];
        self.imgView.layer.borderWidth = .3;
        self.imgView.layer.masksToBounds = YES;
        self.imgView.layer.cornerRadius = WIDTH(45);
        self.imgView.layer.borderColor = [UIColor colorWithWhite:0.600 alpha:1.000].CGColor;
//        self.typeImage = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH(48), HEIGHT(0), WIDTH(20), HEIGHT(15))];
        self.backView = [[UIView alloc]init];
        [self.contentView addSubview:self.backView];
        [self.backView setBackgroundColor:[UIColor whiteColor]];
        
        self.typeImage = [[UIImageView alloc]init];
        [self.typeImage setImage:[UIImage imageNamed:@"iconfont-yuanchuang"]];
        self.typeImage.layer.cornerRadius = 2;
        self.typeImage.layer.masksToBounds = YES;
        self.typeImage.layer.borderWidth = .5;
        self.typeImage.layer.borderColor = [UIColor whiteColor].CGColor;
        [self.backView addSubview:self.typeImage];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, HEIGHT(95),WIDTH(99), HEIGHT(20))];
        [self.contentView addSubview:self.titleLabel];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        self.dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, HEIGHT(120), WIDTH(99), HEIGHT(20))];
        self.dateLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.dateLabel];
        
    }
    return self;
}

- (void)getModel:(LYYRadioModel *)model{
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.album_imgurl] placeholderImage:PLACEHOLDER];
    if (model.type == 1) {
        [self.backView setFrame:CGRectMake(WIDTH(50), 0, WIDTH(40), HEIGHT(20))];
        [self.typeImage setFrame:self.backView.bounds];
    }
    [self.titleLabel setText:model.album_name];
    [self.dateLabel setText:model.update_time];
    self.dateLabel.textColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    if (SCREEN_HEIGHT == 736) {
        self.titleLabel.font = [UIFont systemFontOfSize:16.];
        self.dateLabel.font = [UIFont systemFontOfSize:15.];
    }else if (SCREEN_HEIGHT == 667){
        self.titleLabel.font = [UIFont systemFontOfSize:14.];
        self.dateLabel.font = [UIFont systemFontOfSize:13.];
    }else if (SCREEN_HEIGHT == 568){
        self.titleLabel.font = [UIFont systemFontOfSize:12.];
        self.dateLabel.font = [UIFont systemFontOfSize:11.];
    }else if (SCREEN_HEIGHT == 480){
        self.titleLabel.font = [UIFont systemFontOfSize:10.];
        self.dateLabel.font = [UIFont systemFontOfSize:9.];
    }

    
}

@end
